package com.camunda.workflow.controller.task.user;

import org.camunda.bpm.engine.IdentityService;
import org.camunda.bpm.engine.RuntimeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/userTask")
public class LeaveUserTask {
    @Resource
    private RuntimeService runtimeService;

    @Resource
    private IdentityService identityService;


    @GetMapping("/start/{processKey}")
    public void start(@PathVariable(value = "processKey") String processKey){
        identityService.setAuthenticatedUserId("xiaoming");
        runtimeService.startProcessInstanceByKey(processKey);
    }
}
